package com.parkingspace.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.parkingspace.dao.CarMapper;
import com.parkingspace.entity.Car;
import com.parkingspace.service.ICarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 车辆信息表 服务实现类
 * </p>
 *
 * @author Gapper
 * @since 2021-05-24
 */
@Service
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarService {
    @Resource
    private CarMapper carMapper;

    @Override
    public List<Car> getCarByUId(Long uid) {
        Map<String,Object> map = new HashMap<>();
        map.put("uid",uid);
        List<Car> cars = carMapper.selectByMap(map);
        return cars;
    }

    @Override
    public Boolean addCar(String plateNumber, String drivingPermitNo, String remark, Long uid) {
        Car car = new Car();
        car.setCarType("小型");
        car.setDrivingPermitNo(drivingPermitNo);
        car.setPlateNumber(plateNumber);
        car.setUid(uid);
        car.setSoftdel(0);
        car.setRemark(remark);

        int row = carMapper.insert(car);
        if (row != 0){
            return true;
        }else {
            return false;
        }
    }
}
